const dotenv = require('dotenv')
dotenv.config()

if (!process.env.PARSE_SERVER_APPLICATION_ID)
  throw 'appId is required'

if (!process.env.PARSE_SERVER_MASTER_KEY)
  throw 'masterKey is required'

if (!process.env.PARSE_SERVER_REST_API_KEY)
  throw 'restAPIKey is required'

if (!process.env.PARSE_SERVER_JAVASCRIPT_KEY)
  throw 'javascriptKey is required'

const port = Number(process.env.PORT || 1337)

module.exports = {
  ParseServer: {
    port: port,
    serverURL: process.env.PARSE_SERVER_URL || `http://localhost:${port}/parse`,
    databaseURI: process.env.PARSE_SERVER_DATABASE_URI || 'mongodb://localhost:27017/parse',
    cloud: process.env.PARSE_SERVER_CLOUD || './cloud/main.js',
    appId: process.env.PARSE_SERVER_APPLICATION_ID,
    masterKey: process.env.PARSE_SERVER_MASTER_KEY,
    restAPIKey: process.env.PARSE_SERVER_REST_API_KEY,
    javascriptKey: process.env.PARSE_SERVER_JAVASCRIPT_KEY,
    allowClientClassCreation: process.env.PARSE_SERVER_ALLOW_CLIENT_CLASS_CREATION || false,
    enableAnonymousUsers: process.env.PARSE_SERVER_ENABLE_ANON_USERS || false,
    sessionLength: process.env.PARSE_SERVER_SESSION_LENGTH || 7 * 86400,
    maxLimit: process.env.PARSE_SERVER_MAX_LIMIT || 1000,
    logLevel: process.env.PARSE_SERVER_LOG_LEVEL,
    liveQuery: {
      classNames: []
    }
  }
}
